using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
namespace DAL
{
    public class Archives : DAL.DataManager<Archive>
    {
        private static Archives Instance = new Archives();
        static Archives() { }

        public override string TableName
        {
            get { return @"fstdt_archives"; }
        }

        protected override void CopyToItem(DataRow Row, Archive Item)
        {
            Item.Title = Convert.ToString(Row["ArchiveTitle"]);
        }

        protected override void CopyFromItem(DataManagerQuery query, Archive Item)
        {
            query.AddParam("ArchiveTitle", Item.Title);
        }

        public static Archive Item(Int64 id)
        {
            return Instance.GetItem(id);
        }

        public static List<Archive> All()
        {
            DataManagerQuery query = new DataManagerQuery();
            query.AddSort("ArchiveTitle", Sort.Asc);
            return Instance.GetItems(query);
        }

        public static void Add(Archive Item)
        {
            User curUser = Managers.UserLoginManager.CurrentUser;
            if (curUser != null && curUser.HasPermissions(User.UserStatus.Administrator))
            {
                Instance.Insert(Item);
            }
            else
            {
                throw new Exception("Current user doesn't have enough permissions to add a forum.");
            }
        }

        public static void Save(Archive Item)
        {
            Instance.Update(Item);
        }
    }

    public class Archive : DAL.DataManagerRow
    {
        private string _ArchiveTitle;
        public string Title
        {
            get
            {
                return _ArchiveTitle;
            }
            set
            {
                _ArchiveTitle = value;
            }
        }
    }
}
